/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pras.skripsi.model;

import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Pras
 */
public class HasilTableModel extends AbstractTableModel {

    List<Entity> list = new ArrayList<Entity>();
    private Class editingClass;
    
    int column = 0;

    public List<Entity> getList() {
        return list;
    }

    public void setList(List<Entity> list) {
        this.list = list;
    }

    @Override
    public int getRowCount() {
        return list.size();
    }

    @Override
    public int getColumnCount() {
        return 3;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch (columnIndex) {
            case 0:
                return list.get(rowIndex).getPlates();
            case 1:
                return list.get(rowIndex).getJawaban();
            case 2:
                return list.get(rowIndex).getKunci();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Plates";
            case 1:
                return "Jawaban";
            case 2:
                return "Kunci";
            default:
                return "";
        }
    }

    
    
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return Integer.class;
            case 1:
                if (column < 2) {
                    return String.class;
                } else {
                    return ImageIcon.class;
                }
            case 2:
                 column++;
                if (column <3) {
                    return String.class;
                } else {
                    return ImageIcon.class;
                }
            default:
                return String.class;
        }
    }
}
